package com.shioirikukuri.mapper;

import com.shioirikukuri.entity.UserMemberLevel;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface UserMemberLevelMapper {
	// 插入一条会员等级记录
	@Insert("INSERT INTO user_member_level (name, points_required, points_exchange_rate, description) " +
			"VALUES (#{name}, #{pointsRequired}, #{pointsExchangeRate}, #{description})")
	@Options(useGeneratedKeys = true, keyProperty = "id")
	void insertUserMemberLevel(UserMemberLevel userMemberLevel);

	// 根据ID查询会员等级信息
	@Select("SELECT * FROM user_member_level WHERE id = #{id}")
	UserMemberLevel selectUserMemberLevelById(Long id);

	// 查询所有会员等级信息
	@Select("SELECT * FROM user_member_level")
	List<UserMemberLevel> selectAllUserMemberLevels();

	// 更新会员等级信息
	@Update("UPDATE user_member_level SET name = #{name}, points_required = #{pointsRequired}, " +
			"points_exchange_rate = #{pointsExchangeRate}, description = #{description} WHERE id = #{id}")
	void updateUserMemberLevel(UserMemberLevel userMemberLevel);

	// 根据ID删除会员等级信息
	@Delete("DELETE FROM user_member_level WHERE id = #{id}")
	void deleteUserMemberLevelById(Long id);
}
